package com.ymatou.iapi.trading.operate.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.AutoConfirmReceiveNotifyBean;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.service.AutoConfirmReceiveNotifyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
/**
*自动确认收货通知
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AutoConfirmReceiveNotify {
	private static AutoConfirmReceiveNotifyBean bean;
	private static AutoConfirmReceiveNotifyCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("自动确认收货通知");
	}

	@Before
	public void caseUp() {
		bean = new AutoConfirmReceiveNotifyBean();
		call = new AutoConfirmReceiveNotifyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AutoConfirmReceiveNotify_001() {
		Logger.start(true, "自动确认收货通知成功");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.dispatchedOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			bean.setOrderId(orderId);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("ok", call.getReturnData(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AutoConfirmReceiveNotify_002() {
		Logger.start(true, "自动确认收货-->所有物流单号都签收了。不发送自动确认收货提醒MQ消息");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.dispatchedOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			int userId = placeOrderResp.getUserId();

			String billCode1 = "DB023203094UK";
			String billCode2 = "DB503222327US";

			PlaceOrderService.saveDeliverSummary(orderId, sellerId, billCode1);

			PlaceOrderService.saveDeliverSummary(orderId, sellerId, billCode2);

			bean.setOrderId(orderId);
			bean.setBuyerId(userId);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("ok", call.getReturnData(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AutoConfirmReceiveNotify_003() {
		Logger.start(true, "自动确认收货-->所有物流单号中有未签收的。不发送提醒MQ消息");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.dispatchedOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			int userId = placeOrderResp.getUserId();

			String billCode1 = "3946730180562";
			String billCode2 = "016012783024";

			PlaceOrderService.saveDeliverSummary(orderId, sellerId, billCode1);

			PlaceOrderService.saveDeliverSummary(orderId, sellerId, billCode2);

			bean.setOrderId(orderId);
			bean.setBuyerId(userId);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("ok", call.getReturnData(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AutoConfirmReceiveNotify_004() {
		Logger.start(true, "订单号不存在");
		try {

			int orderId = 1111;

			bean.setOrderId(orderId);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("ok", call.getReturnData(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}